package cn.dankal.lequ.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.dankal.lequ.R;
import cn.dankal.lequ.commom.adapter.ImageViewPageAdapter;

/**
 * 作者： fred on 16/4/19 20:29.
 * 邮箱：fred_kang@dankal.cn
 */
public class MyPicViewPager extends AppCompatActivity {

    ImageView iv1, iv2, iv3, iv4, iv5;

    @Bind(R.id.view_pager)
    ViewPager view_pager;
    float x = 0;
    int currentPos;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mypicviewpager);
        ButterKnife.bind(this);
        currentPos = getIntent().getIntExtra("pagePosition", 0);
        initImage();
    }

    private void initImage() {

        List<ImageView> imageViews = new ArrayList<>();
        iv1 = new ImageView(this);
        iv2 = new ImageView(this);
        iv3 = new ImageView(this);
        iv4 = new ImageView(this);
        iv5 = new ImageView(this);

        iv1.setImageResource(R.mipmap.homepage_independent);
        iv2.setImageResource(R.mipmap.ic_launcher);
        iv3.setImageResource(R.mipmap.iv_head_none);
        iv4.setImageResource(R.mipmap.homepage_comprehensive);
        iv5.setImageResource(R.mipmap.homepage_find);

        imageViews.add(iv1);
        imageViews.add(iv2);
        imageViews.add(iv3);
        imageViews.add(iv4);
        imageViews.add(iv5);


        ImageViewPageAdapter myPicViewPageAdapter = new ImageViewPageAdapter(imageViews, MyPicViewPager.this);
        view_pager.setAdapter(myPicViewPageAdapter);
        view_pager.setCurrentItem(currentPos);
    }
}
